package com.wwu.jobs;

import lombok.extern.slf4j.Slf4j;
import org.quartz.*;

/**
 * @description: 定义任务逻辑，需要实现Job接口并重写execute()方法
 * DisallowConcurrentExecution注解用来避免同一个任务由于执行时间过长导致并发执行
 * @author 一蓑烟雨
 * @version 1.0.0
 * @date 2023-04-16 19:51
 */
@Slf4j
@DisallowConcurrentExecution
public class FirstJob implements Job {
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        //获取触发器cronTrigger传递的参数
        JobDataMap dataMap = context.getTrigger().getJobDataMap();
        log.info("【{}】任务执行开始，执行频率为：{}",dataMap.get("jobDesc"),dataMap.get("jobCron"));
        try {
            Thread.sleep(30000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("【{}】任务执行结束",dataMap.get("jobDesc"));
    }
}
